import 'package:flutter/material.dart';
import 'package:hockey/extensions/jzx_widget_extension.dart';
import 'package:hockey/jzx_apps.dart';
import 'package:hockey/network/jzx_apis.dart';
import 'package:hockey/services/jzx_app.dart';
import 'package:hockey/utils/Jzx_launch.dart';

import 'controller.dart';

class JzxAboutUsView extends GetView<JzxAboutUsController> {
  const JzxAboutUsView({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      extendBodyBehindAppBar: true,
      appBar: const JzxAAppBar(title: 'ABOUT'),
      body: Column(
        children: [
          Assets.images.appLogo
              .image(width: 66.w)
              .paddingOnly(top: kNavigationBarHeight + 51.w),
          _Cell(
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text('Version', style: myAppColors.white.font_16),
                Text(JzxAppService.to.packageInfo?.version ?? '',
                    style: myAppColors.white.font_16),
              ],
            ),
          ),
          _Cell(
            top: 24.w,
            onTap: () {
              JzxLaunch.openUrl(kH5TermConditions);
              JzxLogPvManger.tracking(page: JzxLogPages.terms);
            },
            child: Align(
                alignment: Alignment.centerLeft,
                child: Text('Terms and Conditons',
                    style: myAppColors.white.font_16)),
          ),
          _Cell(
            top: 24.w,
            onTap: () {
              JzxLaunch.openUrl(kH5PrivacyPolicy);
              JzxLogPvManger.tracking(page: JzxLogPages.privacy);
            },
            child: Align(
              alignment: Alignment.centerLeft,
              child: Text(
                'Privacy Policy',
                style: myAppColors.white.font_16,
              ),
            ),
          ),
        ],
      ).backgroud(Assets.images.normalBgv),
    );
  }
}

class _Cell extends StatelessWidget {
  const _Cell({
    super.key,
    required this.child,
    this.top,
    this.onTap,
  });

  final Widget child;

  final double? top;

  final VoidCallback? onTap;

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: onTap,
      child: Container(
        height: 44.w,
        width: double.infinity,
        alignment: Alignment.center,
        margin: EdgeInsets.only(left: 32.w, right: 32.w, top: top ?? 40.w),
        padding: const EdgeInsets.symmetric(horizontal: 21),
        decoration: BoxDecoration(
          color: const Color(0x26FFFFFF),
          borderRadius: BorderRadius.circular(12),
        ),
        child: child,
      ),
    );
  }
}
